package com.mybatis.example;

import com.mybatis.example.entity.User;
import com.mybatis.example.mapper.UserMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class Client {


    public static void main(String[] args) throws IOException {

        InputStream input = Resources.getResourceAsStream("MyBatis.xml");
        SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(input);
        SqlSession sqlSession = sessionFactory.openSession();
        Object one = sqlSession.selectOne("com.mybatis.example.mapper.UserMapper.queryUser", 1);
        System.out.println("第一次查询："+one);
        Object two = sessionFactory.openSession().selectOne("com.mybatis.example.mapper.UserMapper.queryUser", 1);

        System.out.println("第二次查询："+two);

    }
}
